package com.mflex.mpmmic.utils;


import android.content.Context;
import android.media.MediaPlayer;

import com.mflex.mpmmic.R;
import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;

public class MessageUtils {
//    public static void errorMsgAndVoice(Context context, ApiException e) {
//        MediaPlayer mp = MediaPlayer.create(context, R.raw.error_voice);
//        mp.start();
////        if (e.getCode() == 100) {
//        new MaterialDialog.Builder(context)
//                .iconRes(R.drawable.icon_warning)
//                .title(R.string.tip_warning)
//                .content(e.getMessage())
//                .positiveText(R.string.lab_submit)
//                .show();
////        }
////        if (e.getCode() == 200) {
////            new MaterialDialog.Builder(context)
////                    .iconRes(R.drawable.icon_tip)
////                    .title(R.string.tip_infos)
////                    .content(e.getMessage())
////                    .positiveText(R.string.lab_submit)
////                    .show();
////        }
//    }

//    public static void errorMsgAndVoice(Context context, String msg) {
//        MediaPlayer mp = MediaPlayer.create(context, R.raw.error_voice);
//        mp.start();
//
//        new MaterialDialog.Builder(context)
//                .iconRes(R.drawable.icon_warning)
//                .title(R.string.tip_warning)
//                .content(msg)
//                .positiveText(R.string.lab_submit)
//                .show();
//
//    }

    public static void errorMsg(Context context, ApiException e) {
        if (e.getCode() == 100) {
            new MaterialDialog.Builder(context)
                    .iconRes(R.drawable.icon_warning)
                    .title(R.string.tip_warning)
                    .content(e.getMessage())
                    .positiveText(R.string.lab_submit)
                    .show();
        }
        if (e.getCode() == 200) {
            new MaterialDialog.Builder(context)
                    .iconRes(R.drawable.icon_tip)
                    .title(R.string.tip_infos)
                    .content(e.getMessage())
                    .positiveText(R.string.lab_submit)
                    .show();
        }
    }
}
